package com.ppt.android.app

import android.util.Log
import com.google.firebase.FirebaseApp
import com.google.firebase.FirebaseOptions
import com.ppt.android.base.BaseApplication
import com.ppt.android.base.utils.ChangeDefaultFontUtils
import com.ppt.android.utils.AnalyticsUtil
import dagger.hilt.android.HiltAndroidApp
import org.greenrobot.eventbus.EventBus

/**
 * App壳
 *
 * @author ZouJiaCai
 * @since 4/23/21 6:08 PM
 */
@HiltAndroidApp
class AppApplication : BaseApplication() {

    override fun onCreate() {
        // 开启EventBusAPT,优化反射效率 当组件作为App运行时需要将添加的Index注释掉 因为找不到对应的类了
        EventBus
            .builder()
            .installDefaultEventBus()
        super.onCreate()
        Log.d("test","AppApplication")

        val storageOptions = FirebaseOptions.Builder()
            .setProjectId("wallpaper-29336")
            .setApplicationId("1:401283426069:android:6477022d301f73b54b2b1c")
            .setApiKey("AIzaSyCrzXZbogvtjufDt0x3SMoYBCyDxcLfzi4")
            .setStorageBucket("wallpaper-29336.firebasestorage.app")
            .build()

        FirebaseApp.initializeApp(context, storageOptions, "storageFirebase")

        //初始化埋点
        FirebaseApp.initializeApp(this)
        AnalyticsUtil.init(this)


        // 全局替换字体
        ChangeDefaultFontUtils.changeDefaultFont(applicationContext)

//        CoroutineScope(Dispatchers.IO).launch {
//            MobileAds.initialize(this@AppApplication) {}

//        }



    }
}